import BuffUtil from '@/BuffUtil';
import UnitSpellEvent from '@/event/UnitSpellEvent';
import RandomUtil from '@/RandomUtil';
import ArrayUtil from '@/ArrayUtil';
import Buff from '@/Buff';
import MovementCommon from 'code/Core/Common/MovementCommon';
export default class Item_鱼人的清洁器 {
    static id = 'Ayrq';
    static buffId: string = 'buff_item_yurenqingjieqi';
    static buffType: AppBuffType = {
        id: 'buff_item_yurenqingjieqi',
        name: '恶心',
        ubertip: '这TM竟然真是口水',
        art: 'assets\\item\\INV_Misc_Bugsprayer.blp',
        attribute: {
            命中: -0.35,
            attackSpd_p: -0.5,
        },
        dur: 8,
    };
    static missileReach(p: TargetMissileConfig) {
        let r = RandomUtil.randomPercent();
        if (r < 0.95) {
            let buffs = BuffUtil.getUnitBuffs(p.target);
            let bs: Buff[] = [];
            for (let key in buffs) {
                let b = buffs[key];
                if (b.buffType.isDebuff) {
                    bs.push(b);
                }
            }
            let rb = ArrayUtil.randomElement(bs);
            if (rb) {
                rb.destroy();
            }
        } else {
            BuffUtil.addBuff(p.target, Item_鱼人的清洁器.buffId);
        }
    }
    static 释放(x: number, y: number, 来源?: unit, 目标?: unit, d?: any) {
        MovementCommon.TargetMissile({
            missile: 'Abilities\\Spells\\Items\\WandOfNeutralization\\NeutralizationMissile.mdl',
            target: 目标,
            caster: 来源,
            speed: 600,
            radian: 0.3,
            onReach: Item_鱼人的清洁器.missileReach,
        });
    }
    constructor() {
        BuffUtil.registerBuffType(Item_鱼人的清洁器.buffType);
        se.onUnitSpellEffect(Item_鱼人的清洁器.spellEffect, Item_鱼人的清洁器.id);
    }
    static spellEffect(this: void, d: UnitSpellEvent) {
        Item_鱼人的清洁器.释放(d.spellTargetX, d.spellTargetY, d.trigUnit, d.spellTargetUnit, d);
    }
}
